import request from './request.js'

// 通过 ip 地址查询所在城市 API
export const getLocalCity = () => {
  return request({
    method: 'GET',
    url: '/ip',
    params: {
      key: '1ef4e20d33e7c95222ed4c783afa3844',
    },
  })
}

//通过城市名查询 adcode API
export const getCityAdcode = (params) => {
  return request({
    method: 'GET',
    url: '/geocode/geo',
    params: {
      address: params,
      key: '1ef4e20d33e7c95222ed4c783afa3844',
    },
  })
}

//通过 adcode 查询城市实时天气 api
export const getWeatherByAdcodeLive = (params) => {
  return request({
    method: 'GET',
    url: '/weather/weatherInfo',
    params: {
      city: params.city,
      key: '1ef4e20d33e7c95222ed4c783afa3844',
      extensions: 'base',
    },
  })
}

//通过 adcode 查询城市未来4天天气 API
export const getWeatherByAdcodeForecast = (params) => {
  return request({
    method: 'GET',
    url: '/weather/weatherInfo',
    params: {
      city: params.city,
      key: '1ef4e20d33e7c95222ed4c783afa3844',
      extensions: 'all',
    },
  })
}
